package org.zjt.lock;

import java.util.HashMap;
import java.util.List;

public class DeadLock2 {

    public static void fun (int val,int val2) throws InterruptedException {
        synchronized (Integer.valueOf(val)){
            Thread.sleep(10000);
            synchronized (Integer.valueOf(val2)){

            }
        }
    }

    public static void main(String[] args) throws InterruptedException {



        new Thread(() -> {
            try {
                fun(1,2);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();
        Thread t = new Thread(() -> {
            try {
                fun(2,1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });

        t.start();
        t.join();  // 等待线程的执行结束
    }
}
